package initialize

import (
	"context"
	"coolcar/global"

	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
	"go.uber.org/zap"
)

func InitMongo(logger *zap.Logger) {
	mongoClient, err := mongo.Connect(context.Background(), options.Client().ApplyURI("mongodb://localhost:27017/coolcar?readPreference=primary&appname=mongodb-vscode%200.7.0&directConnection=true&ssl=false"))
	if err != nil {
		logger.Fatal("can not connect mongodb: %v", zap.Error(err))
	}
	global.MongoDB = mongoClient.Database("coolcar")
}
